package wnhz.com.business.groupshop.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import wnhz.com.business.R;
import wnhz.com.business.base.BaseActivity;
import wnhz.com.business.base.BaseRVAdapter;
import wnhz.com.business.base.BaseViewHolder;

/**
 * 设置SKU
 */
public class SetSKUActivity extends BaseActivity {


    @BindView(R.id.tv_tt)
    TextView tvTt;
    @BindView(R.id.iv_left)
    ImageView ivLeft;
    @BindView(R.id.lay_actionbar_left)
    RelativeLayout layActionbarLeft;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.iv_addsku)
    TextView ivAddsku;
    @BindView(R.id.recycler_sku)
    RecyclerView recyclerSku;

    private List<String> itemdata = new ArrayList<>();

    public static Intent createIntent(Context context) {
        Intent intent = new Intent(context, SetSKUActivity.class);
        return intent;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set_sku);
        ButterKnife.bind(this);
        //沉浸设置
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            //透明状态栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //透明导航栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

            tvTt.setVisibility(View.VISIBLE);
            //获取到状态栏的高度
            int statusHeight = getStatusBarHeight();
            //动态的设置隐藏布局的高度
            LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) tvTt.getLayoutParams();
            params.height = statusHeight;
            tvTt.setLayoutParams(params);
        }


        initview();
        setRecyclerSku();

    }


    private void initview()
    {

        tvTitle.setText("sku设置");
        recyclerSku.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));
        itemdata.clear();
        for (int i = 0; i < 2; i++) {
            itemdata.add("a"+i);
        }
    }


    private void setRecyclerSku()
    {
        recyclerSku.setAdapter(new BaseRVAdapter(this,itemdata) {
            @Override
            public int getLayoutId(int viewType) {
                return R.layout.item_sku;
            }

            @Override
            public void onBind(BaseViewHolder holder, int position) {
            }

        });
    }

    @OnClick({R.id.iv_left, R.id.iv_addsku})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            //回退
            case R.id.iv_left:
                finish();
                break;
            //创建SKU
            case R.id.iv_addsku:

                startActivity(SendSKUActivity.createIntent(this));
                break;
        }
    }
}
